<!--

    Copyright 2020 StreamSets Inc.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<!doctype html>
<html lang="en">
<head>
  <title>StreamSets Registration</title>
  <link rel="icon" type="image/png" href="assets/favicon.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <!-- compiled CSS --><% styles.forEach( function ( file ) { %>
  <link rel="stylesheet" type="text/css" href="<%= file %>" /><% }); %>
</head>
<body>
  <div class="container login-container">
    <div class="row">
      <div id="loginErrorMessageDivId"
           class="col-xs-6 col-xs-offset-3 col-sm-5 col-sm-offset-4 col-md-4 col-md-offset-4 col-lg-4 col-lg-offset-4 alert alert-danger"
           role="alert">Log In Failed.</div>
    </div>
    <div class="row">
      <div
        class="col-xs-6 col-xs-offset-3 col-sm-5 col-sm-offset-4 col-md-4 col-md-offset-4 col-lg-4 col-lg-offset-4 form-login">
        <div class="img_container">
          <img class="aster-registration" src="assets/logo.png" />
          <p>Linking your Data Collector...</p>
          <i class="fa fa-spinner fa-spin fa-2x"></i>
        </div>
      </div>
    </div>
  </div>
  <script>
    // DO a POST to /rest/v1/aregistration using the query string parameters send to this page.
    const parameters = new URL(window.location).searchParams;
    const form = document.createElement('form');
    form.style.visibility = 'hidden'; // no user interaction is necessary
    form.method = 'POST'; // forms by default use GET query strings
    form.action = '/rest/v1/aregistration';
    for (const [key, value] of parameters) {
      const input = document.createElement('input');
      input.name = key;
      input.value = value;
      form.appendChild(input); // add key/value pair to form
    }
    document.body.appendChild(form); // forms cannot be submitted outside of body
    form.submit(); // send the payload and navigate
  </script>
</body>
</html>
